<html>
<script>
    function _(id) {
        return document.getElementById(id);
    }
</script>
<body>
<form onsubmit="send('v', _('in').value);_('in').value=''; return false;"> 
<input type="text" id="in" />
<input type="submit" value="Send" />
</form>
<input type="button" value="Clear All" onclick="send('c', 'true');" />
<div id="test"></div>
<script>
function send(key, str) {
    request = new XMLHttpRequest();
    request.open('POST', '/abc?' + key + '=' + str, false);
    request.send(null);
    document.getElementById("test").innerHTML = request.responseText;
}

function loop() {
    request = new XMLHttpRequest();
    request.onreadystatechange = mainLoopHandler;
    request.open('GET', '/abc', true);
    request.send(null);
}

function mainLoopHandler() {

    if(request.readyState == 4) {
        document.getElementById("test").innerHTML = request.responseText;
    }
}

a = setInterval("loop()", 1000);
</script>
</body>
</html>
